<%--
  Created by IntelliJ IDEA.
  User: 86177
  Date: 2021/11/17
  Time: 20:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加页面</title>
    <script src="${pageContext.request.contextPath}/static/js/jquery-1.8.3.min.js"></script>
    <link href="${pageContext.request.contextPath}/static/css/index3.css" rel="stylesheet">
</head>
<body>
<form action="add" method="post">
    财务日期:<input type="date" name="finDate"><br><br>
    源账号名称:<input type="text" name="fromname" onblur="addFromId1()">
    源账号:<input type="text" name="fromid" readonly="readonly">
    <input type="hidden" name="fromId"><br><br>
    目标账号名称:<input type="text" name="toname" onblur="addFromId2()">
    目标账号:<input type="text" name="toid" readonly="readonly">
    <input type="hidden" name="toId"><br><br>
    科目编号:<input type="text" name="aimId">
    科目:<input type="text" name="aimName"><br><br>
    借方:<input type="text" name="borrow">
    贷方:<input type="text" name="loan">
    余额:<input type="text" name="money"><br><br>
    摘要:<input type="text" name="context"><br><br>
    <input type="submit" value="添加">
</form>
<script>
    function addFromId1(){
        $.post(
            "getAccountByName",
            {name:$("[name='fromname']").val()},
            function (m){
                $("[name='fromid']").val(m.accountId);
                $("[name='fromId']").val(m.id);
            },"json"
        );
    }
    function addFromId2(){
        $.post(
            "getAccountByName",
            {name:$("[name='toname']").val()},
            function (m){
                $("[name='toid']").val(m.accountId);
                $("[name='toId']").val(m.id);
            }
        );
    }
</script>
</body>
</html>
